package com.shuyun.springdata.showcase.repository;

import com.shuyun.springdata.showcase.domain.Person;
import com.shuyun.springdata.showcase.spesc.CustomerRepository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RestResource;

import java.util.List;

/**
 * Created by feng.ding on 2017/1/6.
 */
//public interface PersonRepository extends CustomerRepository<Person, Long> {
public interface PersonRepository extends JpaRepository<Person, Long>{

            List<Person> findByAddress(String address);

    Person findByNameAndAddress(String name, String address);

    @Query("select p from Person p where p.name = :name and p.address = :address")
    Person withNameAndAddressQuery(@Param("name")String name, @Param("address")String address);

    Person withNameAndAddressNamedQuery(String name, String address);

    //spring-data-rest 默认路径实体类加s eg: persons
//    @RestResource(path = "nameStartsWith", rel = "nameStartsWith")
    Person findByNameStartsWith(String name);

}
